# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=cyclone
pkgver=0.34.0
pkgrel=0
pkgdesc="A compiler for application development with R7RS Scheme"
url="https://justinethier.github.io/cyclone/"
# s390x: ck on s390x does not have ck_pr_cas_8 (used by cyclone)
# See: https://github.com/concurrencykit/ck/issues/178
arch="all !s390x"
license="MIT"
makedepends="ck-dev cyclone-bootstrap"
source="$pkgname-$pkgver.tar.gz::https://github.com/justinethier/cyclone/archive/refs/tags/v$pkgver.tar.gz"

# Since cyclone itself is written in Scheme it needs to be bootstraped.
# For this propose, upstream provides a dedicated cyclone-bootstrap
# repository which includes C files generated by a previous cyclone
# version. We package this as cyclone-init-bootstrap in a separate
# package and compile the original cyclone Scheme sources using it
# initially. From that point onward, we build cyclone using itself.
#
# This is achieved by having both cyclone-init-bootstrap and cyclone
# provide the virtual cyclone-bootstrap package. The latter must have
# the higher provider priority.
#
# See also https://lists.alpinelinux.org/~alpine/devel/%3C33KG0XO61I4IL.2Z7RTAZ5J3SY6%408pit.net%3E
provides="cyclone-bootstrap"
provider_priority=100 # highest

export PREFIX=/usr
export DATADIR=$PREFIX/lib/cyclone

build() {
	# We use a smaller pthread stack size by default,
	# make sure Cyclone configures the stack size manually.
	make CYC_PTHREAD_SET_STACK_SIZE=1
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install
}

sha512sums="
16a30c4343284c4e097b5612b1f399c9098038826c5341a4f86a3d9325afbc5ac9a2b606ade1c63068758c5a9db157ab9a50c001c4fe33ae6de67d25c951b8be  cyclone-0.34.0.tar.gz
"
